/*************************************************************************
	> File Name: P1029.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-01-08 09:37:51
 ************************************************************************/
#include <iostream>
#include <cmath>
using namespace std;

int gcd(int a, int b) {
    return (b ? gcd(b, a % b) :  a);
}

int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

int main() {
    int x, y, cnt = 0;
    cin >> x >> y;
    long long k = x * y;
    for (long long i = 1, I = sqrt(x * y); i <= I; i++) {
        int j = k / i;
        if (gcd(i, j) != x) continue;
        if (lcm(i, j) != y) continue;
        cnt += 1;
        if (i != j) cnt += 1;
    }
    cout << cnt << endl;
    return 0;
}
